﻿using Cheng;
using DG.Tweening;
using GameFramework.Event;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.VFX;

public class PlayerManagr : MonoSingleton<PlayerManagr>
{

    //public Character4D character4D { get; private set; }


    ////人物图片

    //public SpriteRenderer[] sprites { get; private set; }

    //public NPC currentTarget { get; private set; }
    //public bool setAttribute = false;
    //private Animator animator;
    ////天赋带来的属性

    //private Dictionary<string, FloatModifier> talentAttribute = new Dictionary<string, FloatModifier>();
    //private DeedReporter m_deedReporter = null;
    //public Vector3 offset;

    //protected override void OnInit()
    //{
    //    base.OnInit();
    //    m_deedReporter = GetComponent<DeedReporter>();
    //    animator = this.transform.GetComponent<Animator>();
    //    character4D = GetComponent<Character4D>();
    //    sprites = character4D.transform.GetChild(0).FindComponentsInChildren<SpriteRenderer>();

    //    //设置动画

    //    GameEntry.Event.Subscribe(CustomBaseEventArgs.EventId, (object sender, GameEventArgs e) =>
    //    {
    //        CustomBaseEventArgs cbe = (CustomBaseEventArgs)e;
    //        if (cbe.EventName.Contains("Animation"))
    //        {
    //            for (int i = 0; i < cbe._Values.Length; i++)
    //            {
    //                animator.SetAnimatorInfo(cbe._Values[i].ToString());
    //            }
    //        }
    //    });

    //}





    //private void OnCollisionEnter2D(Collision2D collision)
    //{

    //    switch (collision.gameObject.tag)
    //    {
    //        case "Enemy":
    //            //TODO:调整方向
    //            //battle = true;
    //            int direction = -1;
               
              
    //            direction = collision.gameObject.transform.position.x-transform.position.x>0?-1:1;
              
                
    //            //transform.GetChild(0).SetLocalScaleX(-direction* scale);
    //            collision.transform.SetLocalScaleX(direction);
    //            transform.DOLocalMoveX(collision.transform.localPosition.x - 0.3f * direction, 0.05f);
    //            //transform.DOLocalMove(collision.transform.localPosition - Vector3.right * direction*0.3f, 0.05f);
    //            collision.transform.DOLocalMoveX(collision.transform.localPosition.x- 0.3f*direction, 0.05f).OnComplete(()=> {

    //                CombatContext.Instance.AddEntity(CombatContext.Instance.Object2Entities[collision.gameObject], false);
    //                CombatContext.Instance.AddEntity(CombatContext.Instance.Object2Entities[gameObject], true);
    //                //GameEntry.Event.Fire(this, CustomBaseEventArgs.Create("ChangeScene", "Battle"));
    //                var combatFlow = EGamePlay.MasterEntity.Instance.AddChild<CombatFlow>();
    //                combatFlow.ToEnd();
    //                combatFlow.JumpToTime = 600;
    //                combatFlow.Startup(null);
    //            });
               
    //            GameEntry.UI.CloseUIForm(UIFormId.PlayerContralForm);
    //            break;
    //        case "NPC":
           
    //            //GameEntry.UI.OpenUIForm(UIFormId.DialogueForm, collision.gameObject);
    //            GameEntry.Event.Fire(this, CustomBaseEventArgs.Create("ChangeScene", "Battle", collision.gameObject.name));
    //            break;
    //        case "Scene":
    //            GameEntry.Event.Fire(this, CustomBaseEventArgs.Create("ChangeScene", collision.gameObject.name));
    //            break;

    //        case "Armor":
    //            Debug.LogWarning(collision.gameObject.GetComponent<Armor>().ArmorData.TypeId);
    //            break;
    //    }

    //}

    //public virtual void CommitDeed(string tag)
    //{
    //    if (currentTarget == null) return;
    //    m_deedReporter.ReportDeed(tag, currentTarget.factionMember);
    //}
}
